#include "VMPhysicalMemory.h"


//default constructor for VMPhysicalMemory
VMPhysicalMemory::VMPhysicalMemory()
{
	memoryTable = 0; //null address
	wordSize = 0;
	addressSize = 0;
}

//constructor takes in the memory table, word size, and address
//size
VMPhysicalMemory::VMPhysicalMemory(unsigned char** table, unsigned long int word,
			unsigned long int address)
{
	memoryTable = table;
	wordSize = word;
	addressSize = address;
}


//get word size in bits
unsigned long int VMPhysicalMemory::getWordSize()
{
	return wordSize;
}


//get the address size
unsigned long int VMPhysicalMemory::getAddressSize()
{
	return addressSize;
}


//gets a word from memory
unsigned char* VMPhysicalMemory::getWord(unsigned long int address)
{
	return memoryTable[address];
}


//sets a word in memory
void VMPhysicalMemory::setWord(unsigned long int address, unsigned char* word)
{
	memoryTable[address] = word;
}


//sets a set of words from memory
void VMPhysicalMemory::setWords(unsigned long int startAddress, 
		unsigned char** words,
		unsigned long int numberOfWords)
{
	unsigned long int i = 0;
	for(i = 0; i < numberOfWords; i++)
		memoryTable[startAddress+i] = words[i];
}


//gets a set of words from memory
unsigned char** VMPhysicalMemory::getWords(unsigned long int startAddress,
	   		   unsigned long int numberOfWords,
				unsigned char** buffer)
{
	unsigned long int i = 0;
	for(i = 0; i < numberOfWords; i++)
		buffer[i] = memoryTable[startAddress+i];
	return buffer;
}


